<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
	<head>
		<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
		<title>Scope Selectors &mdash; Intype Documentation</title>
		<link rel="stylesheet" href="css/static.css" type="text/css" />
		<link rel="stylesheet" href="css/content.css" type="text/css" />
	</head>
	<body>
		<div id="page"><div id="page-inner">

			<div id="sub-header"><div id="sub-header-inner">
				&nbsp;
			</div></div>

			<div id="cols">

				<div id="nav">
					<div id="nav-inner">
						<h1>Manual</h1>
						<ul>
							<li><a href="introduction.html" class="title"><span>Introduction</span></a></li>
							<li><a href="editing.html" class="title"><span>Editing</span></a>
							<ul>
								<li><a href="selections.html" class="title"><span>Selections</span></a></li>
								<li><a href="find_and_replace.html" class="title"><span>Find & Replace</span></a></li>
							</ul>
							</li>
							<li><a href="preferences.html" class="title"><span>Preferences</span></a>
							<ul>
								<li><a href="appearance_preferences.html" class="title"><span>Appearance Preferences</span></a></li>
							</ul>
							</li>
							
							<li><a href="scopes.html" class="title"><span>Scopes</span></a>
							<ul>
								<li><a href="document_scopes.html" class="title"><span>Document Scopes</span></a></li>
								<li><a href="application_scopes.html" class="title"><span>Application Scopes</span></a></li>
								<li><a href="scope_selectors.html" class="title"><span>Scopes Selectors</span></a></li>
								<li><a href="scope_naming_conventions.html" class="title"><span>Naming Conventions</span></a></li>
							</ul>
							</li>
							
							<li><a href="bundles.html" class="title"><span>Bundles</span></a>
							<ul>
								<li><a href="bundle_items.html" class="title"><span>Bundle Items</span></a></li>
								<li><a href="scopes.html" class="title"><span>Scopes</span></a></li>
								<li><a href="snippets.html" class="title"><span>Snippets</span></a></li>
								<li><a href="languages.html" class="title"><span>Languages</span></a></li>
								<li><a href="built_in_bundles.html" class="title"><span>Built-In Bundles</span></a></li>
							</ul>
							</li>
							<li><span class="title missing"><span>appendix</span></span>
							<ul>
								<li><a href="jasmine.html" class="title"><span>Jasmine</span></a></li>
								<li><a href="regular_expressions.html" class="title"><span>Regular Expressions</span></a></li>
							</ul>
							</li>
						</ul>
					</div>
				</div>

				<div id="content">
					<div id="content-right">
						<div id="content-left">
							<div id="content-inner">
								<h1>Scope Selectors</h1>

<p>Scope selector is similar to a CSS selector. Currently Intype supports only descendant selectors and groupping of selectors.</p>

<h3>Descendant Selectors</h3>

<p>Like in CSS, you can match an element with it's name and class (e.g. <code>div.center</code>), and you can also match a descendant <em>Paragraph</em> of <code>div.class</code> with <code>div.class p</code>. Scope selectors allows you to do the same.</p>

<p>The difference with CSS is that you cannot specify only a class (like <code>.quoted</code>), you always have to specify all parents.</p>

<table class="w">
    <thead>
        <tr>
            <th class="incorrect">Incorrect</th>
            <th class="correct">Correct</th>
        </tr>
    </thead>
    <tr>
        <td class="incorrect"><code>.quoted</code></td>
        <td class="correct"><code>string.quoted</code></td>
    </tr>
    <tr>
        <td class="incorrect"><code>.double</code></td>
        <td class="correct"><code>string.quoted.double</code></td>
    </tr>
    <tr>
        <td class="incorrect"><code>.quoted.double</code></td>
        <td class="correct"><code>string.quoted.double</code></td>
    </tr>
</table>

<p>Some examples:</p>

<table class="w">
    <thead>
        <tr>
            <th>Selector</th>
            <th>Match</th>
        </tr>
    </thead>
    <tr>
        <td class="t"><code>text</code></td>
        <td>Everything in any text document</td>
    </tr>
    <tr>
        <td class="t"><code>text.html</code></td>
        <td>Everything in HTML document</td>
    </tr>
    <tr>
        <td class="t"><code>text.html meta.tag</code></td>
        <td>The tag in HTML document</td>
    </tr>
    <tr>
        <td class="t"><code>text.html meta.tag string</code></td>
        <td>Any **string** in a tag in a HTML document, i.e. <strong>value of attribute</strong></td>
    </tr>
    <tr>
        <td class="t"><code>text.html meta.tag string.quoted.double</code></td>
        <td>The <strong>double-quoted string</strong> in a tag in a HTML document, i.e. <strong>value of attribute in double quotes</strong></td>
    </tr>
</table>

<h3>Substracting Descendant Selectors</h3>

<p>Some cases requires to substract two descendant selectors. Like:</p>

<ul>
<li>Match everything in the tag, but not the attribute values.</li>
<li>Match string, but not escape sequences, or interpolated code. (for example Ruby: <code>"The title is #{title}"</code>; PHP: <code>"The title is ${$title ? $title : 'Untitled'}"</code>.</li>
</ul>

<p>You can substract two descendants with minus between them:</p>

<pre><code>meta.tag.html - string
string - source.ruby
string - source.php
</code></pre>

<h3>Groupping Selectors</h3>

<p>You can specify more than a one descendant selectors. Just separate them with comma:</p>

<pre><code>string.quoted.double, string.quoted.single
</code></pre>

<h3>Ranking</h3>

<p>When multiple selectors are matched, Intype has to rank them to get the best matching. There are two simple rules for this:</p>

<ul>
<li>Descendant closer to the top of the scope wins.
<ul>
<li><code>"string.quoted"</code> wins over <code>"text.html"</code></li>
<li><code>"string.quoted"</code> wins over <code>"text.html meta.tag"</code></li>
</ul></li>
<li>Descendant matching more of the scope wins.
<ul>
<li><code>"string.quoted"</code> wins over <code>"string"</code></li>
<li><code>"text.html string.quoted"</code> wins over <code>"string.quoted"</code></li>
<li><code>"text.html string.quoted"</code> wins over <code>"text.html"</code></li>
</ul></li>
</ul>
							</div>
						</div>
					</div>
				</div>

			</div>

		</div>

		</div>
	</body>
</html>